package com.shop.shard.controller.assembler.user;

import com.shop.shard.controller.command.user.UserAddressCreateCommand;
import com.shop.shard.controller.command.user.UserAddressUpdateCommand;
import com.shop.shard.entity.user.UserAddress;

import java.util.Date;

/**
 * @Description: 代码生成器自动生成
 * @author:
 * @Createed Date: 2019-8-16 10:06:57
 * @ModificationHistory: Who  When  What
 * ---------     -------------   --------------------------------------
 **/
public class UserAddressAssembler{
    public static UserAddress toUserAddress(UserAddressCreateCommand command){
        UserAddress entity = new UserAddress();
        /** 用户id*/
        entity.setUserId(command.getUserId());
        /** 省*/
        entity.setProvince(command.getProvince());
        /** 市*/
        entity.setCity(command.getCity());
        /** 区*/
        entity.setDistrict(command.getDistrict());
        /** 详细地址*/
        entity.setDetail(command.getDetail());
        /** 排序*/
        entity.setSort(command.getSort());
        /** 性别：1-男；2-女*/
        entity.setGender(command.getGender());
        /** 逻辑删除符*/
        entity.setDeleted(command.getDeleted());
        /** 创建时间*/
        entity.setCreateDate(command.getCreateDate());
        /** 更新时间*/
        entity.setUpdateDate(command.getUpdateDate());
        /** 保留字段1*/
        entity.setReserved1(command.getReserved1());
        /** 保留字段2*/
        entity.setReserved2(command.getReserved2());
        Date currentDate = new Date();
        entity.setCreateDate(currentDate);
        entity.setUpdateDate(currentDate);
        return entity;
    }

    public static UserAddress toUserAddress(UserAddressUpdateCommand command){
        UserAddress entity = new UserAddress();
        /** 主键*/
        entity.setAddressId(command.getAddressId());
        /** 用户id*/
        entity.setUserId(command.getUserId());
        /** 省*/
        entity.setProvince(command.getProvince());
        /** 市*/
        entity.setCity(command.getCity());
        /** 区*/
        entity.setDistrict(command.getDistrict());
        /** 详细地址*/
        entity.setDetail(command.getDetail());
        /** 排序*/
        entity.setSort(command.getSort());
        /** 性别：1-男；2-女*/
        entity.setGender(command.getGender());
        /** 逻辑删除符*/
        entity.setDeleted(command.getDeleted());
        /** 创建时间*/
        entity.setCreateDate(command.getCreateDate());
        /** 更新时间*/
        entity.setUpdateDate(command.getUpdateDate());
        /** 保留字段1*/
        entity.setReserved1(command.getReserved1());
        /** 保留字段2*/
        entity.setReserved2(command.getReserved2());
        Date currentDate = new Date();
        entity.setUpdateDate(currentDate);
        return entity;
    }
}